package com.greenhouse.mapper.environment;

import com.greenhouse.model.Environment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface EnvironmentMapper {
    /**
     * 创建名为name的大棚环境信息表
     * @param name
     * @return
     */
        @Insert("create table if not exists ${name} (" +
            "id int primary key auto_increment COMMENT '主键，自动递增'," +
            "create_time datetime not null COMMENT '监测时间'," +
            "content varchar(255) not null COMMENT '监测内容'," +
            "value varchar(50) not null COMMENT '监测数据'," +
            "device_id int not null COMMENT '监测设备ID'" +
            ")")
    Integer createGreanhouserEnvironment(@Param("name") String name);

    @Delete("delete from ${name}")
    Integer deleteUserEquipment(String name);
    @Insert("insert into ${name} " +
            "(create_time,content,value,device_id) " +
            "values" +
            "(#{createTime},#{content},#{value},#{deviceId})")
    Integer insertEnvironment(String name, Environment environment);
}
